// import { login } from "../login"

import Config from "../common/Config"
import UtilTool from "../tools/UtilTool"

// const path = 'http://192.168.1.37:8080'
// // const path = 'http://190.92.212.20'
// // const path = "https://www.coincoin.bio";//正式

//登录
export const login = async (params) =>{
    return await fetch( Config.FETCHPATG+ '/island/login?account=' + params.account + '&sign='+params.sign ,{ 
    // return await fetch( Config.FETCHPATG+ '/boat/login?account=' + params.account + '&sign='+params.sign ,{ 
        method:'get' 
    }).then(res => res.json())
}

//获取版本号
export const version = async () =>{
    return await fetch( Config.FETCHPATG+ '/island/version?ver=1.0.1&pack=island',{ 
    // return await fetch( Config.FETCHPATG+ '/boat/version?ver=1.0.1&pack=boat',{ 
        method:'get' 
    }).then(res => res.json())
}


//获取登录随机数
export const signRandom = async (account) =>{
    UtilTool.printLog(fetch,'fetch');

    let invite = UtilTool.getUrlParamValue('invite')
    invite = invite || "0"

    return await fetch( Config.FETCHPATG+ '/island/signRandom?account=' + account + '&inviter='+invite,{ 
    // return await fetch( Config.FETCHPATG+ '/boat/signRandom?account=' + account ,{ 
        method:'get'
    }).then(res => res.json())
    .catch (err => UtilTool.printLog(err,'x')
    )
}

//获取公钥
export const getPublicKey = async () =>{
    return await fetch( Config.FETCHPATG+ '/island/publickey',{
        method:'get' 
    }).then(res => res.json())
}